package com.lkd.controller;


import com.lkd.service.OrderService;
import com.lkd.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-20
 */
@RestController

public class OrderController {

    @Autowired
    private OrderService orderService;

    //查询指定时间段内的订单数量
    @GetMapping("/api/order-service/report/orderCount")
    public Result getOrderCount(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date start,
                                @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date end){
        Integer count=orderService.getOrderCount(start,end);
        return Result.success(count);
    }

    //查询指定时间段内的销售额数量
    @GetMapping("/api/order-service/report/orderAmount")
    public Result getOrderAmount(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date start,
                                 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date end){
        double amount=orderService.getOrderAmount(start,end);
        return Result.success(amount);
    }
}
